/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.anism.entity;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author tgqm5519
 */
@Entity
@Table(name = "holiday_request")
@SequenceGenerator(name = "seq_pk_request", sequenceName = "seq_pk_request", allocationSize = 1)
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "HolidayRequest.findAll", query = "SELECT h FROM HolidayRequest h"),
    @NamedQuery(name = "HolidayRequest.findById", query = "SELECT h FROM HolidayRequest h WHERE h.id = :id"),
    @NamedQuery(name = "HolidayRequest.findByStartDate", query = "SELECT h FROM HolidayRequest h WHERE h.startDate = :startDate"),
    @NamedQuery(name = "HolidayRequest.findByEndDate", query = "SELECT h FROM HolidayRequest h WHERE h.endDate = :endDate"),
    @NamedQuery(name = "HolidayRequest.findByCurrentStatus", query = "SELECT h FROM HolidayRequest h WHERE h.currentStatus = :currentStatus"),
    @NamedQuery(name = "HolidayRequest.findByType", query = "SELECT h FROM HolidayRequest h WHERE h.type = :type")})
public class HolidayRequest implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "seq_pk_request")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id", nullable = false)
    private Integer id;
    @Column(name = "start_date")
    @Temporal(TemporalType.DATE)
    private Date startDate;
    @Column(name = "end_date")
    @Temporal(TemporalType.DATE)
    private Date endDate;
    @Size(max = 128)
    @Column(name = "current_status", length = 128)
    private String currentStatus;
    @Size(max = 128)
    @Column(name = "type", length = 128)
    private String type;
    @JoinColumn(name = "validator", referencedColumnName = "id")
    @ManyToOne
    private Employee validator;
    @JoinColumn(name = "owner", referencedColumnName = "id")
    @ManyToOne
    private Employee owner;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "request")
    private Collection<RequestHistory> requestHistoryCollection;

    public HolidayRequest() {
    }

    public HolidayRequest(Integer id, Date startDate, Date endDate, String currentStatus, String type) {
        this.id = id;
        this.startDate = startDate;
        this.endDate = endDate;
        this.currentStatus = currentStatus;
        this.type = type;
    }

    public HolidayRequest(Integer id) {
        this.id = id;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public String getCurrentStatus() {
        return currentStatus;
    }

    public void setCurrentStatus(String currentStatus) {
        this.currentStatus = currentStatus;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Employee getValidator() {
        return validator;
    }

    public void setValidator(Employee validator) {
        this.validator = validator;
    }

    public Employee getOwner() {
        return owner;
    }

    public void setOwner(Employee owner) {
        this.owner = owner;
    }

    @XmlTransient
    public Collection<RequestHistory> getRequestHistoryCollection() {
        return requestHistoryCollection;
    }

    public void setRequestHistoryCollection(Collection<RequestHistory> requestHistoryCollection) {
        this.requestHistoryCollection = requestHistoryCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof HolidayRequest)) {
            return false;
        }
        HolidayRequest other = (HolidayRequest) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.anism.entity.HolidayRequest[ id=" + id + " ]";
    }
}
